package com.konsung.ksdc.manager.shop;

import android.app.Activity;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;
import java.util.List;

/**
 * 商品详情展示图片轮播
 * Created by Administrator on 2016/5/18 0018.
 */
public class VpProductDetailAdapter extends PagerAdapter {

    Activity activity;
    List<View> viewList = new ArrayList<View>();

    /**
     * 构造方法
     * @param activity Activity
     * @param data 轮播的图片集合
     */
    public VpProductDetailAdapter(Activity activity, List<View> data) {
        this.activity = activity;
        viewList = data;
    }

    @Override
    public int getCount() {
        return viewList.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(viewList.get(position), 0);
        return viewList.get(position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView(viewList.get(position));
    }

    @Override
    public int getItemPosition(Object object) {
        return super.getItemPosition(object);
    }
}
